<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>用户列表</title>
    <link href="css/style.css" rel="stylesheet" type="text/css"/>
    <script type="text/javascript" src="js/jquery.js"></script>


</head>


<body>
<form id="form1" runat="server" onsubmit="return false;">
    <div class="place">
        <span>位置：</span>
        <ul class="placeul">
            <li><a href="#">首页</a></li>
            <li><a href="#">系统设置</a></li>
            <li><a href="#">用户管理</a></li>
        </ul>
    </div>

    <div class="rightinfo">

        <ul class="seachform">
            <li><label>姓名</label>
                <input type="text" class="scinput" id="txtUserName" th:value="${phone}"/></li>

            <li><label>&nbsp;</label><input id="btnSearch" type="button" class="scbtn" value="查询"/></li>
        </ul>

        <div class="tools">
            <ul class="toolbar">
                <li id="btnAdd"><span><img src="images/t01.png"/></span>分配帐号</li>
                <li id="btnRefuse"><span><img src="images/t03.png"/></span>删除用户</li>
                <li id="btnPush"><span><img src="images/t01.png"/></span>推送</li>

            </ul>
        </div>

        <table class="tablelist">
            <thead>
            <tr>
                <th width="50px"><input type="checkbox" id="chkSelectAll"/></th>
                <th width="50px">序号</th>
                <th width="200px">客户编号/手机号</th>
                <th width="200px">密码</th>
                <th width="200px">微信opend_id</th>
                <th width="80px">状态</th>
                <th width="200px">操作</th>
                <th>&nbsp;</th>
            </tr>
            </thead>
            <tbody>
            <tr th:each="user,iterStat : ${pageInfo.list}">
                <td><input type="checkbox" name="chkSelect" th:value="${user.id}"/></td>
                <td th:text="${iterStat.count}"></td>
                <td th:text="${user.phone}"></td>
                <td th:text="${user.password}"></td>
                <td th:text="${user.wx_open_id}"></td>
                <td th:text="${user.status}=='1'?'正常':'冻结'"></td>
                <td><a   href="javascript:;" class="tablelink"
                       th:onclick="'javascript:edit(\''+${user.id}+'\');'">编辑</a>
                    <a   href="javascript:;" class="tablelink"
                         th:onclick="'javascript:pushHistory(\''+${user.id}+'\');'"  th:text="'推送历史('+${user.count}+')'"> </a>
                    <a   href="javascript:;" class="tablelink"
                         th:onclick="'javascript:push(\''+${user.id}+'\');'">发送通知</a>

                </td>
                <td>&nbsp;</td>
            </tr>
            </tbody>
        </table>
        <div class='pagin' th:include="pagefoot::frag (${pageInfo},@{?1=1(phone=${phone},status=${status})})">
        </div>

    </div>

    <script type="text/javascript">
        $('.tablelist tbody tr:odd').addClass('odd');
    </script>

</form>


<link href="plugin/artDialog/artDialog/skins/blue.css" rel="stylesheet"/>
<script src="plugin/artDialog/artDialog/artDialog.min.js" type="text/javascript"></script>
<script src="plugin/artDialog/artDialog/artDialog.plugins.min.js" type="text/javascript"></script>
<script src="plugin/artDialog/dialog.js" type="text/javascript"></script>
<script type="text/javascript">
    /*<![CDATA[*/

    function getSelectedIds() {
        var items = $('input[name="chkSelect"]');
        var ids = new Array();
        for (var i = 0; i < items.length; i++) {
            if ($(items[i]).attr('checked')) {
                ids.push($(items[i]).val());
            }
        }

        return ids + '';
    }
    function pushs() {
        ids = getSelectedIds();
        if ("" == ids) {
            showNotice("请先选择");
            return;
        }
        location.href = 'push.html?id=' + ids;
    }

    function refuse() {
        ids = getSelectedIds();
        if ("" == ids) {
            showNotice("请先选择");
            return;
        }
        art.dialog(
            {
                content: '确认删除用户？',
                lock: true
            },
            function () {
                $.ajax({
                    url: 'deleteUser',
                    type: 'POST',
                    data: {
                        'ids': ids
                    },
                    dataType: 'json',
                    success: function (data) {
                        if (data.status == '0') {
                            showNotice('删除成功');
                            location.reload();
                        } else {
                            showNotice(data.msg);
                        }
                    }
                });
            },
            function () {
            }
        );
    }

    function add() {
        showIframe('user_edit.html', '分配用户帐号', false, 600, 400);
    }

    function edit(id) {
        showIframe('user_edit.html?id=' + id, '编辑用户帐号', false, 600, 400);
    }
    function push(id) {
        location.href = 'push.html?id=' + id;
    }

    function pushHistory(id) {
        location.href = 'meassgelist.html?id=' + id;
    }
    function search() {
        var userName = $('#txtUserName').val();
        var status = $('#drpStatus').val();
        location.href = '?phone=' + userName   ;
    }

    $(function () {
        $('#chkSelectAll').click(function () {
            $('input[name="chkSelect"]').attr('checked', $('#chkSelectAll').attr('checked'));
        });

        $('#btnAdd').click(function () {
            add();
        });
        $('#btnRefuse').click(function () {
            refuse();
        });

        $('#btnSearch').click(function () {
            search();
        });
        $('#btnPush').click(function () {
            pushs();
        });
    });
    /*]]>*/
</script>

</body>
</html>